package amazon
//
//import (
//	"black_mamba/utils"
//	"encoding/json"
//	"errors"
//	"fmt"
//	"gitee.com/wengo/go-mamba"
//	http "github.com/Danny-Dasilva/fhttp"
//	"github.com/PuerkitoBio/goquery"
//	"strings"
//)
//
//type Methods string
//
//const (
//	POST      Methods = "post"
//	GET       Methods = "get"
//)
//
//type Amazon struct {
//	client   *mamba.Client
//	//Document *goquery.Document
//	//Response *mamba.Response
//	//Base
//	Account *Account
//	history []string
//}
//
//func NewAmazon() *Amazon {
//	//client := mamba.New()
//	//client.SetDebug(false)
//	//client.SetDebugBodyLimit(0)
//	//client.SetProxy(fmt.Sprintf("http://%s:%s@http-dynamic.xiaoxiangdaili.com:10030", "827392040156680192", "AURz6KOT"))
//	//client.SetHeaders(map[string]string{
//	//	//"User-Agent": utils.GetRandomUa(),
//	//	"Accept": 			"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
//	//	//"Accept-Encoding":  {"gzip, deflate, br"},
//	//	"Accept-Language":  "en-US,en;q=0.5",
//	//	"Connection": "keep-alive",
//	//	"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.84 Safari/537.36",
//	//	//"TE":"Trailers",
//	//	"Accept-Encoding":"gzip, deflate, br",
//	//	"upgrade-insecure-requests":"1",
//	//	//"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
//	//})
//	//
//	//client.SetRetryCount(10)
//	//client.SetRetryWaitTime(3 * time.Second)
//	//client.SetTLSClientConfig(&tls.Config{
//	//	CipherSuites: []uint16 {
//	//		tls.TLS_AES_128_GCM_SHA256,
//	//		tls.TLS_AES_256_GCM_SHA384,
//	//		tls.TLS_CHACHA20_POLY1305_SHA256,
//	//		tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
//	//		tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
//	//		tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
//	//		tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
//	//		//tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256,
//	//		//tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
//	//		tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,
//	//		tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,
//	//		tls.TLS_RSA_WITH_AES_128_GCM_SHA256,
//	//		tls.TLS_RSA_WITH_AES_256_GCM_SHA384,
//	//		tls.TLS_RSA_WITH_AES_128_CBC_SHA,
//	//		tls.TLS_RSA_WITH_AES_256_CBC_SHA,
//	//	},
//	//
//	//	MinVersion: tls.VersionTLS12,
//	//	MaxVersion: tls.VersionTLS13,
//	//})
//
//	var cookies []*http.Cookie
//	// "jacquet07609d0176@foxemail.club", "jacquet Philips", "09136d821a"
//	//json.Unmarshal([]byte(`[{"domain":".amazon.com","secure":true,"value":"noskin","expiry":2205215523,"path":"\/","httpOnly":true,"name":"skin"},{"domain":".amazon.com","secure":true,"value":"142-6102101-1398332","expiry":2205215523,"path":"\/","httpOnly":true,"name":"session-id"},{"domain":".amazon.com","secure":true,"value":"2082787201l","expiry":2205215523,"path":"\/","httpOnly":true,"name":"session-id-time"},{"domain":".amazon.com","secure":true,"value":"L5Z9:HK","expiry":2205215523,"path":"\/","httpOnly":true,"name":"sp-cdn"},{"domain":".amazon.com","secure":true,"value":"132-1717023-8284442","expiry":2205215523,"path":"\/","httpOnly":true,"name":"ubid-main"},{"domain":".amazon.com","secure":true,"value":"LBDJA7R2StL7lNyBAxodi2M3z0CTPNRB\/r6qEYDEXcxnV2MSQVy\/BNxlDlhNd319lMsvJwmBblYmjWxZdzL8OYqnBb+ENK\/xZjfvM0XjTNF8cslCENDKCIdJo5+aDh91ghKq5xR+ute2eP6Ri4anWk1vHCDaMOaBJiUlwOi18iqAyuCYgEKibxN1ssvI+r2KYoydF5ETa\/iUNHPgZjwnkNj9S5kSL0dY9tyx7tM5nKzOPzQiPPq8+q+VY59\/BpITvJSq\/2DVQvzbTxkTpi7cVA==","expiry":2205215523,"path":"\/","httpOnly":true,"name":"session-token"},{"domain":".amazon.com","secure":true,"value":"1","expiry":2205215523,"path":"\/","httpOnly":true,"name":"a-ogbcbff"},{"domain":".amazon.com","secure":true,"value":"2Ci1nA2mPz2y@bGJQjPfc0wmnMbxx6@9ZtdcSF7y7yoeMkLoA189puOi?9NMygyA","expiry":2205215523,"path":"\/","httpOnly":true,"name":"x-main"},{"domain":".amazon.com","secure":true,"value":"Atza|IwEBIFyqy2Q9jp3-vbm2AiFr0b2eAvVcKXYuSWB7M7TX57W3ej6sHM5aqv2-iRUyBWFMr-Up3_wvaBmYKr36YpTUKPb5v20sY4T9DRA11VhJ6GluRdnv6T9fzd4xxHrv2zKfoIKYbtNfFh7OILPJeuxBRBJZRREu7GKICQQOU-Cmr3kdqI9N8_A3jLRJPLRTNQE1o_Yyu17XrC5CCbdrNldJXtOnevmfI5ar1gaplJQx_bsHnKJ-A_foq5bA_ny7jrmDXs_aWCXMSSU2bZ4xLoAOiMc4LvVOOEsbqpU_4Ec53uzsUdDTBncI3kDJR9vTs4N7_WNqa9pEP0kOrCbMEp0-leNZYby63vX6EpjpAB0RKAolw22y7dByYgHnYzoVS8O6ew3uPkPD9l_RCgDLDf8vH9dT","expiry":2205215523,"path":"\/","httpOnly":true,"name":"at-main"},{"domain":".amazon.com","secure":true,"value":"69Go6Ti79c7o0TsM\/0iezk5OdQ5QUKC8eA3jHZAS8WM=","expiry":2205215523,"path":"\/","httpOnly":true,"name":"sess-at-main"},{"domain":".amazon.com","secure":true,"value":"Sst1|PQHTy4DjZnBiXA3gcPzRYtGdC7DC7s00qKUCnP7IwsD1poXvVU5FC0KJDCmaa5uI4TbBUZEEBtl9lUTwcI_eit-RxqQaG5wdN9frmlYrasq5dE5AbVoI4CdlY2-pmBjRMdOcqJMD0t1BJvHLwPkHqe101YX1HXXzdZuxvFWNVEbUnldoDsTeJSpsqM8vldS878O8laiL4SC1_Kek6GqheTF5MqALmvY5Ih_01N38XGMsDPi8_2pshbelD_maUOdqzgq2ZyIOj6mOUj-NVTxuOlosKILB6DSNj9j9qMoHA2P5GMBauLcwx2IL61Js7c-pdggySr1OgdifGiTgT_AXaQiyGA","expiry":2205215523,"path":"\/","httpOnly":true,"name":"sst-main"},{"domain":".amazon.com","secure":true,"value":"1DMVQRUo\/K334LICtdqEetoVUeSpXoj09n1wmqwIM2SaLm\/lVB0J\/Yr4BJSstdsJhs73HgbnhNlc2oH6gh1QmZg==","expiry":2205215523,"path":"\/","httpOnly":true,"name":"x-wl-uid"},{"domain":".amazon.com","secure":true,"value":"tb:6RACJK7MFYJK1YAEMT6P+s-None|1574495523036&t:1574495523036&adb:adblk_no","expiry":2205215523,"path":"\/","httpOnly":true,"name":"csm-hit"},{"domain":".amazon.com","secure":true,"value":"49","expiry":2205215523,"path":"\/","httpOnly":true,"name":"monitor_count"},{"domain":".amazon.com","secure":true,"value":"en_US","expiry":2205215523,"path":"\/","httpOnly":true,"name":"lc-main"}]`), &cookies)
//
//	//json.Unmarshal([]byte(`[{"domain":".amazon.com","secure":true,"value":"noskin","expiry":2183089602,"path":"\/","httpOnly":true,"name":"skin"},{"domain":".amazon.com","secure":true,"value":"147-5096180-2512328","expiry":2183089602,"path":"\/","httpOnly":true,"name":"session-id"},{"domain":".amazon.com","secure":true,"value":"2082787201l","expiry":2183089602,"path":"\/","httpOnly":true,"name":"session-id-time"},{"domain":".amazon.com","secure":true,"value":"USD","expiry":2183089602,"path":"\/","httpOnly":true,"name":"i18n-prefs"},{"domain":".amazon.com","secure":true,"value":"1lvKPbJ4prauL\/YO6G2p\/qxa3HQnihh1mT3mLIZJUCU9d7w2Fe5WM+SBmQL6NA4JIV0ypkiLcexUXE9NA8o3VYtxvRWtySKy4ECoKuPWy\/wmZPXi7nFVrKtwMe5iXHh1LRgoatlBxzvY=","expiry":2183089602,"path":"\/","httpOnly":true,"name":"x-wl-uid"},{"domain":".amazon.com","secure":true,"value":"133-4741760-2585816","expiry":2183089602,"path":"\/","httpOnly":true,"name":"ubid-main"},{"domain":".amazon.com","secure":true,"value":"\/Cd0a\/5SCD5LKB0TsYAEnzj5B0nU1X3Y9zF+8uf7ZKwMDZCkVq1l4+LodwNcYgezIN5mDmfnZmAoh8KAb5oo1p0GnX+bYvcb19J20MT+ytba+WJnUQBDNY0mLY1ojgC7UcmEm+tjpprxNwJ5Xu5EhFUrsjDeAIvO85psgK8muhe1QPEda2f+cezIma+Avn9MijzVTZxWlteB2ReOoY9t59T30w+8ib3m+5iSGat2ALi5RdgPidu1v1OqkrC5vmyLRI6alwwFlmdV15hVSvQffg==","expiry":2183089602,"path":"\/","httpOnly":true,"name":"session-token"},{"domain":".amazon.com","secure":true,"value":"1","expiry":2183089602,"path":"\/","httpOnly":true,"name":"a-ogbcbff"},{"domain":".amazon.com","secure":true,"value":"fQfb?G?nVNCe27pp9hJq1EsnAXmd4?T@XXIc@AsXYUwvwI6jSmkHYVT0Xsab5sYE","expiry":2183089602,"path":"\/","httpOnly":true,"name":"x-main"},{"domain":".amazon.com","secure":true,"value":"Atza|IwEBIJ9TYPmX3oB4Iar_zw6PIF0WfF52b9Pg7UgxWpipMbHjvsWtv3lW3KDGSxPld4dmJtnIIn6HTdoLWlvbk328NYbIZWEOUaVJ8ijYvwBXIetLBfLnGbIFUNMLurQAIBgAbAtF9daT9cRCWP8wbypoxh5n5H1tPuxYHUgdZCuoL_V7xBrfP_OaUzw0b_qjrAzjnsBjiMjvlovn5MHKmhzrtPFgbFzzIT1ArZi_wcJpovRcra3MX3I9ShwLAP6ZK_sZ88AJZBg7sTmcLlPyXtBS87HahhgWS12U-aOgVmK0CQHXQDL-hfxA9SSPY6BsJOHbGoaEwqGIgkMWlrYWXJATGybSkGRaFtkjhz6ZGc8LgPtx7aj6xuVnwDwQqMqGgwKqIM4ECmAopnvWhXlrTHZBWfI6","expiry":2183089602,"path":"\/","httpOnly":true,"name":"at-main"},{"domain":".amazon.com","secure":true,"value":"jVPrPgBGCnRF7yN2uml6F1shiXMVblm40fvJGdHEEp8=","expiry":2183089602,"path":"\/","httpOnly":true,"name":"sess-at-main"},{"domain":".amazon.com","secure":true,"value":"Sst1|PQHUFgqcPANAUAgg22gFM2ytC-hIt08X0ZuesqtDqAjgfdsshiLPQtJob5vpzFl1ZQsfooVEt0KoVWpNMlo11XU7DXKawhoyz235ulI9Qhsd6afatz3IG-foA7mkM3QLWS6AuKyWYafsdiAFBuh-H5JhF4kGaHYV4-maNaozcSQ8JFSJ4cX7sKNPipLq5cQ3dQXN3SCvZxx3hzlnZnHW7Qqj8Qkqr6OGJMKVm3q8DerZX5AdvfQMPrtPvpsdCjYUtMLpowhoVCJyst-VMRp8FYnfRK1ZMyJGDz3Gep-v1yS4ebXeo7yXoh1ajaMi6sFcCnFSy-7vEkhbrIC2qQ5szeOS5A","expiry":2183089602,"path":"\/","httpOnly":true,"name":"sst-main"},{"domain":".amazon.com","secure":true,"value":"tb:s-1QEK50UH2L231F209P2Z|1552369585709&t:1552369649709&adb:adblk_no","expiry":2183089602,"path":"\/","httpOnly":true,"name":"csm-hit"}]`), &cookies)
//	//json.Unmarshal([]byte(`[{"domain":".amazon.com","secure":true,"value":"noskin","expiry":2205985597,"path":"\/","httpOnly":true,"name":"skin"},{"domain":".amazon.com","secure":true,"value":"139-0209404-9931358","expiry":2205985597,"path":"\/","httpOnly":true,"name":"session-id"},{"domain":".amazon.com","secure":true,"value":"2082787201l","expiry":2205985597,"path":"\/","httpOnly":true,"name":"session-id-time"},{"domain":".amazon.com","secure":true,"value":"L5Z9:CN","expiry":2205985597,"path":"\/","httpOnly":true,"name":"sp-cdn"},{"domain":".amazon.com","secure":true,"value":"1MJ\/JY1ltBvsoeltcgMv8pQo1fyujWIs970dSK4GvwwONQRxt2V77Y+fANIiO5epVyWN09yFMNSnFFSioMty4Ap190uTb20XVz1URp5fa8e315Jn7kEq2RUj8Bt6TWunBFNWwl0B+Mkk=","expiry":2205985597,"path":"\/","httpOnly":true,"name":"x-wl-uid"},{"domain":".amazon.com","secure":true,"value":"131-4642859-6351925","expiry":2205985597,"path":"\/","httpOnly":true,"name":"ubid-main"},{"domain":".amazon.com","secure":true,"value":"PEgM2erjoPrhY4kB3vUQCEAlnzgFgwuG6bHvMoHqYSmvlugcj2OjdQsdiD0qUAY4Mgo3sO9V5pdt4ngLkJ\/Ym2\/OAYDFppPeF2bTfF20cjGnlTbPTzTdcvBQiJ8jS8+cleJw5dcNYbSHzwUeKC4qnfE76VMUcEvpQX+RU3hg+gq8ULan2XUslUX9msF9+whvkUGDZiKRdO1zOBoh1lljoo6M57GkMqdBlEyOLuYtpb\/Ac9WriITNBfjvgw5llf0sFYZUktnNigbSeXrlQk86mg==","expiry":2205985597,"path":"\/","httpOnly":true,"name":"session-token"},{"domain":".amazon.com","secure":true,"value":"1","expiry":2205985597,"path":"\/","httpOnly":true,"name":"a-ogbcbff"},{"domain":".amazon.com","secure":true,"value":"DK0iOhOxkKYVSxjKCpbwnMzyKNpnCUaEfldA4qfLo60SoVQs6Q94r0wwOpcTmLSK","expiry":2205985597,"path":"\/","httpOnly":true,"name":"x-main"},{"domain":".amazon.com","secure":true,"value":"Atza|IwEBIGZJ3WJnr7IKe5L9cAc37mXlLv9Lh_wPnbRrDQ1-OdX0QUpIVcgHenccY5f8fHbAyd78t-5vrE-IwuMvVC0StQv2b6NWfrzWJyzTay73DqSA5nAjScrxW3kuGw5piPAuntNAkcIOUf7dA-0x_Ht7qdVWsGemOcDkbCUC9vxv62apKB4K-bSMAnVhnOPJ2NdRRyZP_yDEF7Fwfd0wilfFFgFC2KR9D9179wyVFquLcHNpD6sqzUUmONnp0H8XL3LOpDSCTobQT7WjqAb4H2-STHI98NnDsjNJV5bkB_HRBlKNx1qEgdQdMcqBSWdJw5zXu9F81-wsg9nNduQNer2xumleFCzxu-CV9TGOCiySuW4ar_BnDcchvyXEHSayfOGu7w0LNrit35TZjDVlzAROajws","expiry":2205985597,"path":"\/","httpOnly":true,"name":"at-main"},{"domain":".amazon.com","secure":true,"value":"F9IlOcDScgV\/9SJE9uTbv7mqt6ZbNs64V6OAvCZ5y1A=","expiry":2205985597,"path":"\/","httpOnly":true,"name":"sess-at-main"},{"domain":".amazon.com","secure":true,"value":"Sst1|PQHxvhMRVV1dKoI_C4hKMKD2C5VJMHfcO_qZShiDEN5vcCcvvJ4JVHUA3Z0EI1CC07IseS-tdGre8ln1gFnUrDSxqtfXGRUYQlmJmMCOQmq49QLUC_2BwgdQdQEDK6w3WTYR2zHANeWbtNFxjVDLNBzDUM50aDpFKUQnFDXbjzAdUVTcIXX9WVcgts4B-3x8inULqUi5kJFwECNdxz67lrAQt8Fsz3MJ4vsxS6NdG4r_3U8EBoZXSiWxPmaZSWwNrjQC6UGj86IEcUHaICbyVUe_bRTHZ6PjDP84o0CdTR_tHbjhr_mdpBxE_d0ZEPVrTfUVKL__BYsyuYcqYUwZxi1YvQ","expiry":2205985597,"path":"\/","httpOnly":true,"name":"sst-main"},{"domain":".amazon.com","secure":true,"value":"en_US","expiry":2205985597,"path":"\/","httpOnly":true,"name":"lc-main"},{"domain":".amazon.com","secure":true,"value":"tb:s-7M4SLD5O1W4YS79VR152|1575265581089&t:1575265647089&adb:adblk_no","expiry":2205985597,"path":"\/","httpOnly":true,"name":"csm-hit"}]`), &cookies)
//	json.Unmarshal([]byte(`[{"domain":".amazon.com","secure":true,"value":"noskin","expiry":2206061622,"path":"\/","httpOnly":true,"name":"skin"},{"domain":".amazon.com","secure":true,"value":"142-4595607-6769850","expiry":2206061622,"path":"\/","httpOnly":true,"name":"session-id"},{"domain":".amazon.com","secure":true,"value":"2082787201l","expiry":2206061622,"path":"\/","httpOnly":true,"name":"session-id-time"},{"domain":".amazon.com","secure":true,"value":"L5Z9:CN","expiry":2206061622,"path":"\/","httpOnly":true,"name":"sp-cdn"},{"domain":".amazon.com","secure":true,"value":"1uVKQOZ3r5EstA0df+i1NkUB01pdDNxiwdfbhHVFNomWi8RoE9IWMDNvBFAkWnxHCJUKsonm7T26V\/zmpWmddWkh8v21txttW7TErGgFuazD7FYTrM1EJuQdA+UsAbPYdqSRWlu6xBwU=","expiry":2206061622,"path":"\/","httpOnly":true,"name":"x-wl-uid"},{"domain":".amazon.com","secure":true,"value":"133-1292752-1087565","expiry":2206061622,"path":"\/","httpOnly":true,"name":"ubid-main"},{"domain":".amazon.com","secure":true,"value":"bflSZfAfMS46NpsPWg1T6WyVRA8ytNdNIs8A8rYh+aeWCWDY+ez0V06lfmOcmyLWJhFgE5eJ9Hj8rtRpxX2yXv9H6\/8Ck8q46MoO5KbruFa0i2dMi5H9AXOap0fUIgnnhYK2xrg5DHX9LIzr2O0eS\/mK1AZXF3jeJ5vrHaUFHHm7hfiUh\/ZfHnmR4jSv9JmYPqAckkvlGDyNRZcLa\/zhD4PxFFKY2ZiBIfHG6f+p20aULp9pO1Q6Mj0HrKJ\/bs52XnQ5AtER1HtYv4LrMl92LA==","expiry":2206061622,"path":"\/","httpOnly":true,"name":"session-token"},{"domain":".amazon.com","secure":true,"value":"1","expiry":2206061622,"path":"\/","httpOnly":true,"name":"a-ogbcbff"},{"domain":".amazon.com","secure":true,"value":"mMIw2qQH6cWBdswGyGwVT5r9aWqf2paEZHWTSi@iF4AAlVKuwsdFSR2GxXm1FMkX","expiry":2206061622,"path":"\/","httpOnly":true,"name":"x-main"},{"domain":".amazon.com","secure":true,"value":"Atza|IwEBIDQ_ZTHWOzSEu0W2PG-dqQyAkXERub_IaQ9g6EJM9LEH9pGNmF9s64fxqnXTOdAbdke-GX_4W0J90ntHEBPv3dlpX1Cc8JGmKpTkE_3W8f9p2X4gpOrvV4av2uM_SUwArV_wTlavqrWMWALluQswrcxh8deFzguFta6otRksPQ-pnBg4DzBDqUf0iESQgPzXykR3LXSYQfp9e3UHkQbSlwNLts3IOxdLfRwtGIva1YxqzRtklfz09kvGP9yQhBwuLPgDg_YdcbawEaFLq8LDQ9WIiOTio7WZr2YmUAqLweb2XmOt4d5KtTv1Wg94Y4gLhLxZmWOB82dP_LVoseAkR7VikjBh1WLtUAhY7njah5uTuwLYThpbMCGXeWPR56-ubgsF0R1o30lAF31-3RrVIsEt","expiry":2206061622,"path":"\/","httpOnly":true,"name":"at-main"},{"domain":".amazon.com","secure":true,"value":"AoIvQCjlV8HhAoSsDoQLIrUfqMWJQs7prw89kVp3xq0=","expiry":2206061622,"path":"\/","httpOnly":true,"name":"sess-at-main"},{"domain":".amazon.com","secure":true,"value":"Sst1|PQFPte3YpDSM4OzbcgXB1jnzCwiJGOzAL49EcCkvHULiUrCgaV8fgu3Z0wZvLqlkn1nE2s38SlIDpPNSRYy-IS26_Tu7ICoHfPa1cT_dgNWzPZLYPESYL8f2TYMHDZQ7ewYFrwZysllGl89tLalr6ASTUcjfl8TXpUbBdOR8GTZj26CxKmR3WFi7cZprooIzN5N8QhFFnnXtjbUTeutvPyfekVa2C6G5JjIL7fPncAHGl95dsMoN-YgA4hQFL-3JD8CjtKQ7QSDf8jpY3hy39osiF0J9esuyAy7c1R6KBqeGNCkH4ux7gS29LvrN-1u7_vrDcSvwzT6gY3bwVLpGXkKF2A","expiry":2206061622,"path":"\/","httpOnly":true,"name":"sst-main"},{"domain":".amazon.com","secure":true,"value":"en_US","expiry":2206061622,"path":"\/","httpOnly":true,"name":"lc-main"},{"domain":".amazon.com","secure":true,"value":"tb:s-9IC88U15NO87LE554PXS|1575341607154&t:1575341659154&adb:adblk_no","expiry":2206061622,"path":"\/","httpOnly":true,"name":"csm-hit"}]`), &cookies)
//	//
//
//	//base := Base{
//	//	client:   utils.GetHttpClient(nil, cookies),
//	//}
//	//return &Amazon{
//	//	client:   utils.GetHttpClient(nil, cookies)
//	//}
//
//	amz := &Amazon{
//		client:   utils.GetHttpClient(nil, cookies),
//	}
//
//	amz.Account = NewAccount(amz)
//
//	return amz
//
//}
//
//
//
//
//// 设置BaseUrl
////
//// url: 链接
//func (b *Amazon) SetBaseUrl(urlstr string) {
//	b.client.SetBaseURL(urlstr)
//}
//
//func (b *Amazon) request(method Methods, url string, header, data, query map[string]string) (resp *mamba.Response, documennt *goquery.Document, err error) {
//	req := b.client.R()
//
//	if header != nil {
//		req.SetHeaders(header)
//	}
//
//	if len(b.history) > 0 {
//		req.SetHeader("Referer", b.history[len(b.history) - 1])
//	}
//
//	if data != nil {
//		req.SetFormData(data)
//	}
//
//	if query != nil {
//		req.SetQueryParams(query)
//	}
//
//	switch method {
//	case POST:
//		resp, err = req.Post(url)
//	case GET:
//		resp, err = req.Get(url)
//	}
//
//	if err != nil {
//		return nil, nil, err
//	}
//
//	documennt, err = b.parseResponse(resp.String())
//
//	b.addHistory(url)
//
//	return resp, documennt, err
//}
//
//// 添加请求历史记录
////
//// method: 请求方式, POST, GET, OPTION, HEAD
////
//// url: 网址
////
//// header: 请求头部
////
//// data: Post内容
////
//// query: Url参数
//func (b *Amazon) addHistory(url string)  {
//
//	if !strings.Contains(url, "https") {
//		url = fmt.Sprintf("%s%s", b.client.BaseURL, url)
//	}
//
//	b.history = append(b.history, url)
//}
//
//// 处理request返回的数据
////
//// Response: Response数据
//func (b *Amazon) parseResponse(html string) (document *goquery.Document, err error) {
//
//	if strings.Contains(html, "opfcaptcha") {
//		return nil, errors.New("robots")
//	}
//
//	document, err = goquery.NewDocumentFromReader(strings.NewReader(html))
//
//	return
//}
//
//// 提取表单数据
////
//// document: 当前返回的Response
//func (a *Amazon) ExtractFormData(document *goquery.Document, formId string) (string, Methods, map[string]string) {
//	var formData = make(map[string]string)
//
//	action, _ := document.Find(formId).Attr("action")
//	var method Methods
//	methodType, _ := document.Find(formId).Attr("method")
//
//	methodType = strings.ToLower(methodType)
//	if methodType == "post" {
//		method = POST
//	} else if methodType == "get" {
//		method = GET
//	}
//
//	document.Find(fmt.Sprintf("%s input", formId)).Each(func(i int, selection *goquery.Selection) {
//		name, _ := selection.Attr("name")
//		if name != "" {
//			value, _ := selection.Attr("value")
//			formData[name] = value
//		}
//	})
//
//	return action, method, formData
//}

/*
// 提取CsrfToken数据
//
// document: 当前返回的Response
func (a *Amazon) ExtractCsrfToken(document *goquery.Document) (token string) {
	token, _ = document.Find("#glowValidationToken").Attr("value")

	return
}

// 检查产品可售
//
// document: 当前返回的Response
func (a *Amazon) CheckListingAvailable(document *goquery.Document) bool {
	if document.Find("#outOfStock").Length() > 0 {
		return false
	}

	return true
}



// 登录
//
//csrf: csrf token
func (a *Amazon) Login(email, username, password string, document *goquery.Document) (resp *mamba.Response, newDocument *goquery.Document, err error) {
	action, method, loginFormData := a.ExtractFormData(document, "form[name='signIn']")
	//loginFormData["appAction"] = "SIGNIN_PWD_COLLECT"
	loginFormData["password"] = password
	//loginFormData["metadata1"] = `ECdITeCs:+UvNK7U6OpYJmcbk2pE0JJD5wHU7Rfu1vXp+Apnh+mF6n3Ug7ljxHXXXd5BJ89N6N9AO5fYryUP/W73mPeV+9jgg0lNkTJiaQEmDDrtPtIJdYcJNll0YBvSdZWR9CjvMxsvxZedjh2Lfyf6s5Jb1OHLdAH/PqWRioHZywbomvYd0nBgmV2PVS+jGKS6P9TnpDcexFlRJT6wNUwFK19uhrh2OQpfAHj6cLXHcGl/1AA5QT3VSazKYaWHR6KVwKnJSoPFlwvbPTz5lXnmOB7yg3Y7zjkS82mWSja/o7rzxwZpZQ+QGiqdPPy9BVhIwMy/W0f7T406TEzyCBLy9b8aYhSYOanjz8SWRoojXxEG9jV2IDV4iP/5Qh2/cfZxVaejJe71kXeSzW3N55ZP7SY/Xz8TFmMLaimvtqpZMY9ngW52KMFvJWBemdMGq9LcZGO+GUnGARnbnnQ9ALYzg+L9RCMFEsWAl1Lf4R2s59zcUN6RFg8XJ7vuFfZChHKu+Um/PoP2AAgTdJE8dXu7dSrTKJhjoG+KrHShxr+DD194eh8USIjWcrLmcBk7BZqfAe+w099CDxM5IMgd9PurmAs/jzA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iGwTfxH2GXZWBMyIcznjfhxgiquYHH2neBNrK6q7bd4NtejtV/n2CicsAoTZ4=`
	resp, newDocument, _ = a.Submit(action, method, loginFormData)
	return
}

func (a *Amazon) AccountFixup(document *goquery.Document) (newDocument *goquery.Document, err error) {
	link, _ := document.Find("#ap-account-fixup-phone-skip-link").Attr("href")
	_, newDocument, _ = a.Navigate(link)
	return
}



// 选择地址
//
//csrf: csrf token
func (a *Amazon) AddressSelection(csrf string) (resp *mamba.Response, document *goquery.Document, err error) {
	headers := map[string]string{
		"anti-csrftoken-a2z": csrf,
		"X-Requested-With": "XMLHttpRequest",
		"referer": a.client.BaseURL,
	}

	query := map[string]string{
		"deviceType": "desktop",
		"pageType": "Gateway",
		"storeContext": "NoStoreName",
		"actionSource": "desktop-modal",
	}

	return a.request(GET, "/gp/glow/get-address-selections.html", headers, nil, query)
}

func (a *Amazon) AddShippingAddress(document *goquery.Document) (resp *mamba.Response, newDocument *goquery.Document, err error) {
	action, method, addressFormData := a.ExtractFormData(document, "#address-ui-address-form")
	addressFormData["address-ui-widgets-countryCode"] = "US"
	addressFormData["address-ui-widgets-enterAddressFullName"] = "valentin Parge"
	addressFormData["address-ui-widgets-enterAddressPhoneNumber"] = "909 772 9182"
	addressFormData["address-ui-widgets-enterAddressLine1"] = "6269 Davidson St"
	addressFormData["address-ui-widgets-enterAddressLine2"] = ""
	addressFormData["address-ui-widgets-enterAddressCity"] = "Chino"
	addressFormData["address-ui-widgets-enterAddressStateOrRegion"] = "CA"
	addressFormData["address-ui-widgets-enterAddressPostalCode"] = "91710"
	addressFormData["address-ui-widgets-use-as-my-default"] = "true"

	resp, newDocument, err = a.Submit(action, method, addressFormData)

	return
}
// 修改地址
func (a *Amazon) ChangeAddress(html string) (err error) {
	formData := map[string]string{
		"locationType": "LOCATION_INPUT",
		"zipCode": "00601",
		"storeContext": "generic",
		"deviceType": "web",
		"pageType": "Gateway",
		"actionSource": "glow",
		"almBrandId": "undefined",
	}

	reg, _ := regexp.Compile(`CSRF_TOKEN\s*:\s*"([^"]+)"`)
	matcher := reg.FindStringSubmatch(html)
	if len(matcher) > 0 {
		_, _, err = a.request(POST,
			"/gp/delivery/ajax/address-change.html",
			map[string]string{
				"anti-csrftoken-a2z": matcher[1],
				"X-Requested-With":   "XMLHttpRequest",
				"referer":            a.client.BaseURL,
			},
			formData,
			nil)

	}

	return
}

// 从bestSeller页面获取Listing Url
func (a *Amazon) GetListingUrlByBestSeller(document *goquery.Document) (selection *goquery.Selection) {
	return document.Find("#zg-ordered-list li.zg-item-immersion span.a-list-item div span.zg-item > a:first-child")
}

// 从Listing页面获取父Asin
func (a *Amazon) ExtractParentAsin(html string) string {
	matcher := regexp.MustCompile(`"parentAsin"\s?:\s?"([^"]+)"`)
	parentAsin := matcher.FindStringSubmatch(html)
	if len(parentAsin) > 0 {
		return parentAsin[1]
	}

	return ""
}

// 从Listing页面获取变体
func (a *Amazon) ExtractVariations(html string) map[string]string {
	matcher := regexp.MustCompile(`"dimensionToAsinMap"\s?:\s?({[^}]+})`)
	//
	//body := a.Response.String()

	value := matcher.FindStringSubmatch(html)
	var dimensionToAsinMap map[string]string
	if len(value) > 0 {
		json.Unmarshal([]byte(value[1]), &dimensionToAsinMap)
	}

	return dimensionToAsinMap

	//matcher, _ = regexp.Compile(`variationValues"\s?:\s?({.+})`)
	//variationValues := matcher.FindString(resp.String())
	//
	//matcher, _ = regexp.Compile(`asinVariationValues"\s?:\s?({.+})`)
	//asinVariationValues := matcher.FindString(resp.String())
	//
	//matcher, _ = regexp.Compile(`dimensionValuesData"\s?:\s?({.+})`)
	//dimensionValuesData := matcher.FindString(resp.String())
	//
	//matcher, _ = regexp.Compile(`asinToDimensionIndexMap"\s?:\s?({.+})`)
	//asinToDimensionIndexMap := matcher.FindString(resp.String())

}

// 添加购物车
func (a *Amazon) AddCart(document *goquery.Document) (newDocument *goquery.Document, err error) {
	action, method, data := a.ExtractFormData(document,"#addToCart")
	delete(data, "gift-wrap")
	_, newDocument, err = a.Submit(action, method, data)
	return
}

// 获取ASIN库存
func (a *Amazon) GetStock(document *goquery.Document) map[string]string {
	content := document.Find(".a-alert-content p").Text()

	if strings.Contains(content, "per customer") {
		return map[string]string{
			"status": "error",
			"reason": "limit",
		}
	}

	matcher, _ := regexp.Compile(`than the ([\d]+) available`)
	results := matcher.FindStringSubmatch(content)

	if len(results) > 0 {
		return map[string]string{
			"status": "success",
			"qty": results[1],
		}
	}

	html, _ := document.Html()
	ioutil.WriteFile("error.html", []byte(html), 0644 )

	return map[string]string{
		"status": "error",
		"reason": "unknown",
	}
}

// 创建收货地址
func (a *Amazon) Checkout(document *goquery.Document) (newDocument *goquery.Document, err error) {
	action, _, queryData := a.ExtractFormData(document,"#gutterCartViewForm")

	queryData["cartInitiateId"] = strconv.Itoa(int(time.Now().UnixNano() / 1e6))
	queryData["isToBeGiftWrapped"] = "0"
	queryData["isToBeGiftWrappedBefore"] = "0"

	// 开始下单
	_, newDocument, err = a.Submit(action, GET, queryData)

	return
}


// 创建收货地址
func (a *Amazon) CreateShippingAddress(document *goquery.Document) (newDocument *goquery.Document, err error) {
	_, method, shippingFormData := a.ExtractFormData(document, "#address-ui-checkout-form")

	purchaseId, _ := document.Find("input[name='purchaseId']").Attr("value")

	shippingFormData["purchaseId"] = purchaseId
	shippingFormData["address-ui-widgets-countryCode"] = "US"
	shippingFormData["address-ui-widgets-enterAddressFullName"] = "valentin Parge"
	shippingFormData["address-ui-widgets-enterAddressPhoneNumber"] = "909 772 9182"
	shippingFormData["address-ui-widgets-enterAddressLine1"] = "6269 Davidson St"
	shippingFormData["address-ui-widgets-enterAddressLine2"] = ""
	shippingFormData["address-ui-widgets-enterAddressCity"] = "Chino"
	shippingFormData["address-ui-widgets-enterAddressStateOrRegion"] = "CA"
	shippingFormData["address-ui-widgets-enterAddressPostalCode"] = "91710"

	// 创建地址
	resp, newDocument, _ := a.Submit(`/a/addresses/ajax/widgets/create`, method, shippingFormData)

	// 获取addressId
	addressId := gjson.Get(resp.String(), "createOrEditAddressResponse.addressId").String()

	// 跳转到下一步
	_, newDocument, _ = a.Submit(`/gp/buy/shared/handlers/async-continue.html/ref=ox_shipaddress_add_new_addr`, POST, map[string]string{
		"action": "select-shipping",
		"addressID": addressId,
		"purchaseId": purchaseId,
		"isClientTimeBased": "1",
		"handler": "/gp/buy/addressselect/handlers/continue.html",
	})

	return newDocument, err
}


// 获取cc表单
func (a *Amazon) GetCreditCardForm(document *goquery.Document) (newDocument *goquery.Document, err error) {
	html, _ := document.Html()
	//matcher := regexp.MustCompile(`"secureFormTarget":"(ApxSecureIframe-pp-[\w]+-[\d]+)"`)
	//matchResult := matcher.FindAllStringSubmatch(html, -1)
	//var frameName string
	//if len(matchResult) > 0 {
	//	frameName = matchResult[0][1]
	//}
	//
	//matcher = regexp.MustCompile(`"parentWidgetInstanceId":"([\w]+)"`)
	//matchResult = matcher.FindAllStringSubmatch(html, -1)
	//var parentWidgetInstanceId string
	//if len(matchResult) > 0 {
	//	parentWidgetInstanceId = matchResult[0][1]
	//}

	//widgetState, _ :=  document.Find("input[name='ppw-widgetState']").Attr("value")
	var widgetState string
	matcher := regexp.MustCompile(`"serializedState":"([^"]+)"`)
	matchResult := matcher.FindAllStringSubmatch(html, -1)
	if len(matchResult) > 0 {
		widgetState = matchResult[0][1]
	}
	paymentInfo := map[string]string{
		"widgetState": widgetState,
		"returnUrl":"/gp/buy/payselect/handlers/apx-submit-continue.html",
		"clientId":"YA:Wallet", //1
		//"clientId":"Checkout", //1
		"usePopover":"true",
		"maxAgeSeconds":"7200",
		"iFrameName": fmt.Sprintf(`ApxSecureIframe-pp-%s-%d`, uniuri.NewLen(6), rand.Int()),
		"parentWidgetInstanceId": uniuri.NewLen(12),
		"hideAddPaymentInstrumentHeader":"true",
		"creatablePaymentMethods":"CC",
	}

	_, newDocument, err = a.Submit(`https://apx-security.amazon.com/cpe/pm/register`, POST, paymentInfo)

	return
}

// 提交cc表单
func (a *Amazon) CreateCreditCard(document *goquery.Document) (newDocument *goquery.Document, err error) {
	html, _ := document.Html()
	var customerId string
	matcher := regexp.MustCompile(`"customerId":"([^"]+)"`)
	matchResult := matcher.FindAllStringSubmatch(html, -1)
	if len(matchResult) > 0 {
		customerId = matchResult[0][1]
	}
	action, method, paymentFormData := a.ExtractFormData(document, "form[id^='pp-']")

	paymentFormData["addCreditCardNumber"] = "5165804436344829"
	paymentFormData["ppw-accountHolderName"] = "Carolyn Tingle"
	paymentFormData["ppw-expirationDate_month"] = "5"
	paymentFormData["ppw-expirationDate_year"] = "2026"


	paymentFormData["ppw-jsEnabled"] = "true"

	//action = fmt.Sprintf(`https://apx-security.amazon.com/payments-portal/data/f1/widgets2/v1/customer/%s/continueWidget?sif_profile=APX-Encrypt-All-NA`, customerId)
	action = fmt.Sprintf(`https://apx-security.amazon.com/payments-portal/data/widgets2/v1/customer/%s/continueWidget?sif_profile=APX-Encrypt-All-NA`, customerId)
	_, newDocument, err = a.Submit(action, method, paymentFormData)

	return
}

// 设置为默认的信用卡支付
func (a *Amazon) SetDefaultCreditCard(document *goquery.Document) (newDocument *goquery.Document, err error) {
	html, _ := document.Html()

	html = strings.ReplaceAll(html, `\&#34;`, "")
	html = strings.ReplaceAll(html, `&#34;`, "")
	html = strings.ReplaceAll(html, `\n`, "")
	html = strings.ReplaceAll(html, `\"`, `"`)

	var customerId string
	matcher := regexp.MustCompile(`"customerId":"([^"]+)"`)
	matchResult := matcher.FindAllStringSubmatch(html, -1)
	if len(matchResult) > 0 {
		customerId = matchResult[0][1]
	}

	document, _ = goquery.NewDocumentFromReader(strings.NewReader(html))
	action, method, formData := a.ExtractFormData(document, "form")

	action = fmt.Sprintf(`https://apx-security.amazon.com/payments-portal/data/widgets2/v1/customer/%s/continueWidget`, customerId)
	_, newDocument, err = a.Submit(action, method, map[string]string{
		"ppw-jsEnabled": "true",
		"ppw-widgetState": formData["ppw-widgetState"],
		"ppw-widgetEvent:SavePaymentMethodDetailsEvent": "",
		"ie": "UTF-8",
		"ppw-updateEverywhereAddCreditCard": "updateEverywhereAddCreditCard",
	})

	return
}

// 设置付款方式，CC和分期付款affirm
func (a *Amazon) SetPaymentMethod(document *goquery.Document) (newDocument *goquery.Document, err error) {
	action, method, selectPaymentFormData := a.ExtractFormData(document, ".pmts-select-payment-instrument-form")

	_, newDocument, err = a.Submit(action, method, selectPaymentFormData)

	return
}

// 建立订单
func (a *Amazon) PlaceOrder(document *goquery.Document) (newDocument *goquery.Document, err error) {
	action, method, placeOrderFormData := a.ExtractFormData(document, "#spc-form")
	_, newDocument, err = a.Submit(action, method, placeOrderFormData)

	return
}

*/

